﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Vehicle.Web.Pages.Post
{
    /// <summary>
    /// Copyright (C) M-Tear团队
    /// 文 件 名：Post_Add.aspx.cs
    /// 版    本：v1.00.0000
    /// 创建标识：2009-09-03   Created by 孙成杰 V1.00.0000
    /// 功能说明：公告添加页面类
    /// 注意事项：无
    /// 
    /// 更新记录：
    /// 
    /// </summary>
    public partial class Post_Add :Vehicle.Web.Component.PageBase
    {
        
        #region ---基本变量实例化---
        BLL.Post b_Post = new BLL.Post();//实例化Post逻辑层
        BLL.Log b_Log = new Vehicle.BLL.Log();
        #endregion

        #region---基本操作--
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }
        /// <summary>
        /// 添加公告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Add_Click(object sender, EventArgs e)
        {
            //判断是否有相同的公告标题
            if (b_Post.GetModel(new Vehicle.Model.ComponentsInfo("Post", "P_Title", this.txt_P_Title.Text.Trim(), "P_ID")).Rows.Count == 0)
            {
                b_Post.Add(new Model.PostInfo(txt_P_Title.Text.Trim(), Vehicle.Common.TextHelper.StringToDateTime(DateTime.Now.ToString()), txt_P_Name.Text.Trim(), Vehicle.Common.TextHelper.CheckStr(txt_P_Note.Text)));//添加公告
                b_Log.Add(new Vehicle.Model.LogInfo(session_ID, DateTime.Now, "成功添加标题为《" + txt_P_Title.Text.Trim() + "》的公告信息"));//添加日志
                Vehicle.Common.MessageHelper.AlertRedirect("添加成功", "Main.aspx");
            }
            else
            {
                Vehicle.Common.MessageHelper.Alert("此公告的标题系统已经存在,请重新填写");
            }
        }
        #endregion
    }
}
